<?php
/**
 * Created by PhpStorm.
 * User: gqn
 * Date: 2016/5/16
 * Time: 15:43
 */

namespace Admin\Controller;
class OrderStatusController extends CommonController{

	
     public function User(){
		 $menu_id=$_GET['id'];
		 $jur=jur_str($menu_id,$this->user_id);
		 $data = M('config_status')->where("user_type = 1")->order('status asc')->select();
		 $unserver = array(1,2,-3);
		 $server = array(-2,3,4,5,6,7);
		 $pro = array(8,9,11,12,13,14);
		 $fin = array(10,-1,15);
		 foreach($data as $k=>$v){
			if(in_array($data[$k]['status'], $unserver)){
				$data[$k]['type'] = '待服务';
			}
			 if(in_array($data[$k]['status'], $server)){
				 $data[$k]['type'] = '服务中';
			 }
			 if(in_array($data[$k]['status'], $pro)){
				 $data[$k]['type'] = '维保中';
			 }
			 if(in_array($data[$k]['status'], $fin)){
				 $data[$k]['type'] = '已完成';
			 }
		}
		 $this->breadcrumb1='基础数据管理';
		 $this->breadcrumb2='订单状态管理';
		 $this->breadcrumb3='用户端状态';
		 $this->assign('update',$jur['is_update']);// 赋值数据集
		 $this->assign('delete',$jur['is_delete']);// 赋值数据集
		 $this->assign('status',$data);
		 $this->display('index');
	 }

	 public function master(){
		 $menu_id=$_GET['id'];
		 $jur=jur_str($menu_id,$this->user_id);
		 $data = M('config_status')->where("user_type = 2")->order('status asc')->select();
		 $unserver = array(1,2,-3);
		 $server = array(-2,3,4,5,6,7);
		 $pro = array(8,9,11,12,13,14);
		 $fin = array(10,-1,15);
		 foreach($data as $k=>$v){
			 if(in_array($data[$k]['status'], $unserver)){
				 $data[$k]['type'] = '待服务';
			 }
			 if(in_array($data[$k]['status'], $server)){
				 $data[$k]['type'] = '服务中';
			 }
			 if(in_array($data[$k]['status'], $pro)){
				 $data[$k]['type'] = '维保中';
			 }
			 if(in_array($data[$k]['status'], $fin)){
				 $data[$k]['type'] = '已完成';
			 }
		 }
		 $this->breadcrumb1='基础数据管理';
		 $this->breadcrumb2='订单状态管理';
		 $this->breadcrumb3='师傅端状态';
		 $this->assign('status',$data);
		 $this->assign('update',$jur['is_update']);// 赋值数据集
		 $this->assign('delete',$jur['is_delete']);// 赋值数据集
		 $this->display('index');
	 }

	public function edit(){
		if(IS_POST){
			$status_id = I('post.status_id');
			$user_type = I('post.user_type');
			$data['id']= $status_id;
			$data['name'] = I('post.name');
			$data['content'] = I('post.content');
			$data['content1'] = I('post.content1');
			$save = M('config_status')->save($data);
			if($save){
				if($user_type =='1') {
					operatelog('用户端状态','3',$status_id);
					echo 1;
					exit;
				}else{
					operatelog('师傅端状态','3',$status_id);
					echo 2;
					exit;
				}
			}else{
				echo -1;
				exit;
			}
		}
		$id = I('get.id');
		$type = I('get.type');
		$this->breadcrumb1='基础数据管理';
		$this->breadcrumb2='订单状态管理';
		$this->breadcrumb4='编辑';
		if($type =='1'){
			$this->breadcrumb3='用户端状态';
		}else{
			$this->breadcrumb3='师傅端状态';
		}
		$inf = M('config_status')->where("id = $id")->select();
		$this->assign('inf',$inf);
		$this->assign('type',$type);
		$this->display();
	}

}
?>